Merge pull request #5961 from mikeller/replace_pointy_includes
[betaflight.git] / docs / development / Building in Mac OS X.md
blobddad2e706e85e54b643a03dca37387dabad0efd6
1 # Building in Mac OS X
3 Building in Mac OS X can be accomplished in just a few steps:
5 * Install general development tools (clang, make, git)
6 * Install ARM GCC 4.9 series compiler
7 * Checkout Cleanflight sourcecode through git
8 * Build the code
10 ## Install general development tools (clang, make, git)
12 Open up a terminal and run `make`. If it is installed already, you should see a message like this, which means that you
13 already have the required development tools installed:
15 ```
16 make: *** No targets specified and no makefile found.  Stop.
17 ```
19 If it isn't installed yet, you might get a popup like this. If so, click the "install" button to install the commandline
20 developer tools:
22 ![Prompt to install developer tools](assets/mac-prompt-tools-install.png)
24 If you just get an error like this instead of a helpful popup prompt:
26 ```
27 -bash: make: command not found
28 ```
30 Try running `xcode-select --install` instead to trigger the popup.
32 If that doesn't work, you'll need to install the XCode development environment [from the App Store][]. After
33 installation, open up XCode and enter its preferences menu. Go to the "downloads" tab and install the 
34 "command line tools" package.
36 [from the App Store]: https://itunes.apple.com/us/app/xcode/id497799835
38 ## Install ARM GCC 4.9 series compiler
40 Cleanflight is built using the 4.9 series GCC compiler provided by the [GNU Tools for ARM Embedded Processors project][].
42 Hit the "all downloads" link on the right side of the GNU Tools for ARM page to view [the older releases][]. Grab the
43 Mac installation tarball for the latest version in the 4.9 series (e.g. 4.9-2015q2). Move it somewhere useful 
44 such as a `~/development` folder (in your home directory) and double click it to unpack it. You should end up with a 
45 folder called `~/development/gcc-arm-none-eabi-4_9-2015q2/`.
47 Now you just need to add the `bin/` directory from inside the GCC directory to your system's path. Run `nano ~/.profile`. Add a
48 new line at the end of the file which adds the path for the `bin/` folder to your path, like so:
50 ```
51 export PATH=$PATH:~/development/gcc-arm-none-eabi-4_9-2015q2/bin
52 ```
54 Press CTRL+X to exit nano, and answer "y" when prompted to save your changes.
56 Now *close this terminal window* and open a new one. Try running:
58 ```
59 arm-none-eabi-gcc --version
60 ```
62 You should get output similar to:
64 ```
65 arm-none-eabi-gcc.exe (GNU Tools for ARM Embedded Processors) 4.9.3 20150529 (release) [ARM/embedded-4_9-branch revision 224288]
66 Copyright (C) 2014 Free Software Foundation, Inc.
67 This is free software; see the source for copying conditions.  There is NO
68 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
69 ```
71 If `arm-none-eabi-gcc` couldn't be found, go back and check that you entered the correct path in your `~/.profile` file.
73 [GNU Tools for ARM Embedded Processors project]: https://launchpad.net/gcc-arm-embedded
74 [the older releases]: https://launchpad.net/gcc-arm-embedded/+download
76 ## Checkout CleanFlight sourcecode through git
78 Enter your development directory and clone the [Cleanflight repository][] using the "HTTPS clone URL" which is shown on
79 the right side of the Cleanflight GitHub page, like so:
81 ```
82 git clone https://github.com/cleanflight/cleanflight.git
83 ```
85 This will download the entire Cleanflight repository for you into a new folder called "cleanflight".
87 [CleanFlight repository]: https://github.com/cleanflight/cleanflight
89 ## Build the code
91 Enter the cleanflight directory and run `make TARGET=NAZE` to build firmware for the Naze32. When the build completes,
92 the .hex firmware should be available as `obj/cleanflight_NAZE.hex` for you to flash using the Cleanflight
93 Configurator.
95 ## Updating to the latest source
97 If you want to erase your local changes and update to the latest version of the Cleanflight source, enter your
98 cleanflight directory and run these commands to first erase your local changes, fetch and merge the latest
99 changes from the repository, then rebuild the firmware:
102 git reset --hard
103 git pull
105 make clean TARGET=NAZE
106 make TARGET=NAZE